/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package GM.util;

import GM.Action;
import GM.ActionType;
import GM.AdGoal;
import GM.Agent;
import GM.Attribute;
import GM.AttributeType;
import GM.ContributionLink;
import GM.Definition;
import GM.Entity;
import GM.Event;
import GM.GMPackage;
import GM.Goal;
import GM.GoalDiagram;
import GM.Mapping;
import GM.Multiplicity;
import GM.Operation;
import GM.Parameter;
import GM.RefType;
import GM.Reference;
import GM.RefinementLink;
import GM.State;

import java.util.Map;

import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.common.util.ResourceLocator;

import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.util.EObjectValidator;

/**
 * <!-- begin-user-doc -->
 * The <b>Validator</b> for the model.
 * <!-- end-user-doc -->
 * @see GM.GMPackage
 * @generated
 */
public class GMValidator extends EObjectValidator {
	/**
	 * The cached model package
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static final GMValidator INSTANCE = new GMValidator();

	/**
	 * A constant for the {@link org.eclipse.emf.common.util.Diagnostic#getSource() source} of diagnostic {@link org.eclipse.emf.common.util.Diagnostic#getCode() codes} from this package.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see org.eclipse.emf.common.util.Diagnostic#getSource()
	 * @see org.eclipse.emf.common.util.Diagnostic#getCode()
	 * @generated
	 */
	public static final String DIAGNOSTIC_SOURCE = "GM";

	/**
	 * A constant with a fixed name that can be used as the base value for additional hand written constants.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private static final int GENERATED_DIAGNOSTIC_CODE_COUNT = 0;

	/**
	 * A constant with a fixed name that can be used as the base value for additional hand written constants in a derived class.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final int DIAGNOSTIC_CODE_COUNT = GENERATED_DIAGNOSTIC_CODE_COUNT;

	/**
	 * Creates an instance of the switch.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public GMValidator() {
		super();
	}

	/**
	 * Returns the package of this validator switch.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EPackage getEPackage() {
	  return GMPackage.eINSTANCE;
	}

	/**
	 * Calls <code>validateXXX</code> for the corresponding classifier of the model.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected boolean validate(int classifierID, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) {
		switch (classifierID) {
			case GMPackage.GOAL:
				return validateGoal((Goal)value, diagnostics, context);
			case GMPackage.OPERATION:
				return validateOperation((Operation)value, diagnostics, context);
			case GMPackage.REFINEMENT_LINK:
				return validateRefinementLink((RefinementLink)value, diagnostics, context);
			case GMPackage.AGENT:
				return validateAgent((Agent)value, diagnostics, context);
			case GMPackage.ENTITY:
				return validateEntity((Entity)value, diagnostics, context);
			case GMPackage.STATE:
				return validateState((State)value, diagnostics, context);
			case GMPackage.EVENT:
				return validateEvent((Event)value, diagnostics, context);
			case GMPackage.AD_GOAL:
				return validateAdGoal((AdGoal)value, diagnostics, context);
			case GMPackage.ACTION:
				return validateAction((Action)value, diagnostics, context);
			case GMPackage.CONTRIBUTION_LINK:
				return validateContributionLink((ContributionLink)value, diagnostics, context);
			case GMPackage.GOAL_DIAGRAM:
				return validateGoalDiagram((GoalDiagram)value, diagnostics, context);
			case GMPackage.PARAMETER:
				return validateParameter((Parameter)value, diagnostics, context);
			case GMPackage.DEFINITION:
				return validateDefinition((Definition)value, diagnostics, context);
			case GMPackage.MAPPING:
				return validateMapping((Mapping)value, diagnostics, context);
			case GMPackage.OBJECT:
				return validateObject((GM.Object)value, diagnostics, context);
			case GMPackage.ATTRIBUTE:
				return validateAttribute((Attribute)value, diagnostics, context);
			case GMPackage.REFERENCE:
				return validateReference((Reference)value, diagnostics, context);
			case GMPackage.REF_TYPE:
				return validateRefType((RefType)value, diagnostics, context);
			case GMPackage.ACTION_TYPE:
				return validateActionType((ActionType)value, diagnostics, context);
			case GMPackage.MULTIPLICITY:
				return validateMultiplicity((Multiplicity)value, diagnostics, context);
			case GMPackage.ATTRIBUTE_TYPE:
				return validateAttributeType((AttributeType)value, diagnostics, context);
			default:
				return true;
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateGoal(Goal goal, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(goal, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(goal, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(goal, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(goal, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(goal, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(goal, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(goal, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(goal, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(goal, diagnostics, context);
		if (result || diagnostics != null) result &= validateGoal_IsLeafe(goal, diagnostics, context);
		if (result || diagnostics != null) result &= validateGoal_SatisfactionRange(goal, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the IsLeafe constraint of '<em>Goal</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String GOAL__IS_LEAFE__EEXPRESSION = "if(leafe = true) then (ref = null) else (ref <> null) endif";

	/**
	 * Validates the IsLeafe constraint of '<em>Goal</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateGoal_IsLeafe(Goal goal, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(GMPackage.Literals.GOAL,
				 goal,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL",
				 "IsLeafe",
				 GOAL__IS_LEAFE__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * The cached validation expression for the SatisfactionRange constraint of '<em>Goal</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String GOAL__SATISFACTION_RANGE__EEXPRESSION = "satisfactionLevel<=1 and satisfactionLevel>=0";

	/**
	 * Validates the SatisfactionRange constraint of '<em>Goal</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateGoal_SatisfactionRange(Goal goal, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(GMPackage.Literals.GOAL,
				 goal,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL",
				 "SatisfactionRange",
				 GOAL__SATISFACTION_RANGE__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateOperation(Operation operation, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(operation, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateRefinementLink(RefinementLink refinementLink, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(refinementLink, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(refinementLink, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(refinementLink, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(refinementLink, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(refinementLink, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(refinementLink, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(refinementLink, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(refinementLink, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(refinementLink, diagnostics, context);
		if (result || diagnostics != null) result &= validateRefinementLink_RefinementLoop(refinementLink, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the RefinementLoop constraint of '<em>Refinement Link</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String REFINEMENT_LINK__REFINEMENT_LOOP__EEXPRESSION = "not target->includes(myFather)";

	/**
	 * Validates the RefinementLoop constraint of '<em>Refinement Link</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateRefinementLink_RefinementLoop(RefinementLink refinementLink, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(GMPackage.Literals.REFINEMENT_LINK,
				 refinementLink,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL",
				 "RefinementLoop",
				 REFINEMENT_LINK__REFINEMENT_LOOP__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateAgent(Agent agent, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(agent, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(agent, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(agent, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(agent, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(agent, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(agent, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(agent, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(agent, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(agent, diagnostics, context);
		if (result || diagnostics != null) result &= validateAgent_InglobeAllOut(agent, diagnostics, context);
		if (result || diagnostics != null) result &= validateAgent_InglobeAllIn(agent, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the InglobeAllOut constraint of '<em>Agent</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String AGENT__INGLOBE_ALL_OUT__EEXPRESSION = "write->includesAll(operat.out)";

	/**
	 * Validates the InglobeAllOut constraint of '<em>Agent</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateAgent_InglobeAllOut(Agent agent, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(GMPackage.Literals.AGENT,
				 agent,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL",
				 "InglobeAllOut",
				 AGENT__INGLOBE_ALL_OUT__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * The cached validation expression for the InglobeAllIn constraint of '<em>Agent</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String AGENT__INGLOBE_ALL_IN__EEXPRESSION = "read->includesAll(operat._'in')";

	/**
	 * Validates the InglobeAllIn constraint of '<em>Agent</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateAgent_InglobeAllIn(Agent agent, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(GMPackage.Literals.AGENT,
				 agent,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL",
				 "InglobeAllIn",
				 AGENT__INGLOBE_ALL_IN__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateEntity(Entity entity, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(entity, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateState(State state, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(state, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateEvent(Event event, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(event, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateAdGoal(AdGoal adGoal, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(adGoal, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateAction(Action action, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(action, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateContributionLink(ContributionLink contributionLink, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(contributionLink, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateGoalDiagram(GoalDiagram goalDiagram, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(goalDiagram, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateParameter(Parameter parameter, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(parameter, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateDefinition(Definition definition, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(definition, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateMapping(Mapping mapping, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(mapping, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateObject(GM.Object object, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(object, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateAttribute(Attribute attribute, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(attribute, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateReference(Reference reference, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(reference, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateRefType(RefType refType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return true;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateActionType(ActionType actionType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return true;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateMultiplicity(Multiplicity multiplicity, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return true;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateAttributeType(AttributeType attributeType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return true;
	}

	/**
	 * Returns the resource locator that will be used to fetch messages for this validator's diagnostics.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public ResourceLocator getResourceLocator() {
		// TODO
		// Specialize this to return a resource locator for messages specific to this validator.
		// Ensure that you remove @generated or mark it @generated NOT
		return super.getResourceLocator();
	}

} //GMValidator
